package com.mo.design.pattern.creational.object_pool;

import java.util.ArrayList;
import java.util.List;

public class ResourcePool {

    List<Resource> resourceList = new ArrayList<Resource>();

    public Resource acquireResource() {
        if (resourceList == null || resourceList.isEmpty()) {
            Resource resource = new Resource();
            resourceList.add(resource);
            return  resource;
        } else {
            return resourceList.remove(0);
        }
    }

    public void releaseResource(Resource resource) {
        resourceList.add(resource);
























































































































































































































































































































































































































































    }
}
